export async function createRegion(regionName,map,level){//获取行政区划
    if(regionName == null){
      return ;
    }
    let district = new AMap.DistrictSearch({
        // 返回行政区边界坐标等具体信息
        extensions: "all",
        // 设置查询行政区级别为 区
        level: level == null ? "district":level,
      });
    await district.search(regionName, function (status, result) {
        
        // 获取合肥市的边界信息
        let bounds = result.districtList[0].boundaries;
        let polygons = [];
        if (bounds) {
          for (var i = 0, l = bounds.length; i < l; i++) {
            //生成行政区划polygon
            let polygon = new AMap.Polygon({
              map: map,
              strokeWeight: 1,
              path: bounds[i],
              fillOpacity: 0.7,
              fillColor: "#CCF3FF",
              strokeColor: "#CC66CC",
            });
            polygons.push(polygon);
          }
          // 地图自适应
          map.setFitView();
        }
      });
}